//
//  NSMutableIndexSet+GL.m
//  GLLibDemo
//
//  Created by huang long on 2017/7/19.
//  Copyright © 2017年 历山大亚. All rights reserved.
//

#import "NSMutableIndexSet+GL.h"

@implementation NSMutableIndexSet (GL)

- (void)intersectSet:(NSIndexSet *)otherSet{
    
    NSIndexSet *removeIndex = [self indexesWithOptions:(NSEnumerationReverse) passingTest:^BOOL(NSUInteger idx, BOOL * _Nonnull stop) {
        return [otherSet containsIndex:idx];
    }];
    [self removeAllIndexes];
    [self addIndexes:removeIndex];
}


- (void)minusSet:(NSIndexSet *)otherSet{
    NSIndexSet *removeIndex = [otherSet indexesWithOptions:(NSEnumerationReverse) passingTest:^BOOL(NSUInteger idx, BOOL * _Nonnull stop) {
        return ![self containsIndex:idx];
    }];
    [self removeAllIndexes];
    [self addIndexes:removeIndex];
}

- (void)removeAllObjects{
    [self removeAllIndexes];
}

- (void)unionSet:(NSIndexSet *)otherSet{
    NSIndexSet *removeIndex = [otherSet indexesWithOptions:(NSEnumerationReverse) passingTest:^BOOL(NSUInteger idx, BOOL * _Nonnull stop) {
        return ![self containsIndex:idx];
    }];
    [self addIndexes:removeIndex];
}

@end
